VERSION 5.00
Object = "{2B16AE89-350D-4A56-A3E2-A46C22F5FFD6}#12.0#0"; "UniDataGrid.ocx"
Begin VB.Form frmDatabase 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Connect to Access (MDB)"
   ClientHeight    =   5400
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7920
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5400
   ScaleWidth      =   7920
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command2 
      BackColor       =   &H00F0F0F0&
      Caption         =   "Command2"
      Height          =   450
      Left            =   7080
      TabIndex        =   5
      Top             =   4380
      Width           =   795
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H00FFFFFF&
      ForeColor       =   &H00000000&
      Height          =   345
      Left            =   1845
      TabIndex        =   0
      Text            =   "hocbong>0"
      Top             =   4830
      Width           =   5040
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00F0F0F0&
      Caption         =   "Filter"
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   4830
      Width           =   1635
   End
   Begin VB.TextBox txtSQL 
      BackColor       =   &H00FFFFFF&
      ForeColor       =   &H00000000&
      Height          =   405
      Left            =   1830
      TabIndex        =   2
      Text            =   "Select masv,(hosv & ' ' & tensv) as Hovaten from sinhvien"
      Top             =   4320
      Width           =   5070
   End
   Begin VB.CommandButton cmdSQLStatement 
      BackColor       =   &H00F0F0F0&
      Caption         =   "SQL Command"
      Height          =   375
      Left            =   105
      TabIndex        =   1
      Top             =   4320
      Width           =   1635
   End
   Begin UniDataGrid.UniGrid UniGrid1 
      Height          =   4170
      Left            =   105
      TabIndex        =   4
      Top             =   90
      Width           =   7740
      _ExtentX        =   13653
      _ExtentY        =   7355
      BeginProperty FontHeader {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty FontCell {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColorHeader =   0
      ForeColorCell   =   0
      SelectFullRow   =   -1  'True
      Style           =   1
      MultiSelect     =   -1  'True
      RowHeight       =   20
      GridLine        =   -1  'True
      ColorGridLine   =   14737632
      ColorSelectedRow=   16643308
      ColorBorderSelectedRow=   16504504
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Visible         =   0   'False
      Begin VB.Menu mnuFileNew 
         Caption         =   "&New"
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFileOpen 
         Caption         =   "&Open"
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuFileClose 
         Caption         =   "&Close"
      End
      Begin VB.Menu mnuFileBar1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileSave 
         Caption         =   "&Save"
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuFileSaveAs 
         Caption         =   "Save &As..."
      End
      Begin VB.Menu mnuFileSaveAll 
         Caption         =   "Save A&ll"
      End
      Begin VB.Menu mnuFileBar2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileProperties 
         Caption         =   "Propert&ies"
      End
      Begin VB.Menu mnuFileBar3 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFilePrintSetup 
         Caption         =   "Print Set&up..."
      End
      Begin VB.Menu mnuFilePrintPreview 
         Caption         =   "Print Pre&view"
      End
      Begin VB.Menu mnuFilePrint 
         Caption         =   "&Print..."
         Shortcut        =   ^P
      End
      Begin VB.Menu mnuFileBar4 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileSend 
         Caption         =   "Sen&d..."
      End
      Begin VB.Menu mnuFileBar5 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "E&xit"
      End
   End
End
Attribute VB_Name = "frmDatabase"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub mnuFileClose_Click()
  MsgBox "Close Code goes here!"
End Sub

Private Sub mnuFileExit_Click()
  'unload the form
  Unload Me
End Sub

Private Sub mnuFileNew_Click()
  MsgBox "New File Code goes here!"
End Sub

Private Sub mnuFileOpen_Click()
  MsgBox "Open Code goes here!"
End Sub

Private Sub mnuFilePrint_Click()
  MsgBox "Print Code goes here!"
End Sub

Private Sub mnuFilePrintPreview_Click()
  MsgBox "Print Preview Code goes here!"
End Sub

Private Sub mnuFilePrintSetup_Click()
  MsgBox "Print Setup Code goes here!"
End Sub

Private Sub mnuFileProperties_Click()
  MsgBox "Properties Code goes here!"
End Sub

Private Sub mnuFileSave_Click()
  MsgBox "Save File Code goes here!"
End Sub

Private Sub mnuFileSaveAll_Click()
  MsgBox "Save All Code goes here!"
End Sub

Private Sub mnuFileSaveAs_Click()
  MsgBox "Save As Code goes here!"
End Sub

Private Sub mnuFileSend_Click()
  MsgBox "Send Code goes here!"
End Sub
Private Sub cmdSQLStatement_Click()
    UniGrid1.SQL = txtSQL.Text
    UniGrid1.ReBind
    UniGrid1.AutoRetrieveField
End Sub

Private Sub Command1_Click()
    UniGrid1.Filter = Text1.Text
End Sub

Private Sub Command2_Click()
    Form_Load
    Me.Caption = UniGrid1.Columns(0).Caption
End Sub

Private Sub Form_Load()
    UniGrid1.SQL = "select * from sinhvien order by masv"
    UniGrid1.Database = App.Path & "\QLSinhvien.mdb"
    'UniGrid1.SQL = "select * from post"
    'UniGrid1.ConnectToMySQL "5.1", "localhost", "mydata", "root", ""
    Call UniGrid1.AutoRetrieveField
    UniGrid1.Columns(1).AllowZeroLength = False
    UniGrid1.Columns(2).AllowZeroLength = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    frmStart.Show
End Sub

Private Sub UniGrid1_CellClick(ByVal ColumnIndex As Long, ByVal RowIndex As Long, ByVal X As Long, ByVal Y As Long)
    Me.Caption = UniGrid1.Columns(ColumnIndex).CellValue(RowIndex)
End Sub

Private Sub UniGrid1_ColumnClick(ByVal ColumnIndex As Long)
    UniGrid1.Columns(ColumnIndex).Sort = IIf(UniGrid1.Columns(ColumnIndex).Sort = 1, 2, 1)
    UniGrid1.Columns.Sort ColumnIndex
    UniGrid1.SQL = "select * from sinhvien order by " & UniGrid1.Columns(ColumnIndex).Caption & IIf(UniGrid1.Columns(ColumnIndex).Sort = Descending, " DESC", "")
    UniGrid1.ReBind
    UniGrid1.ReDrawRows
End Sub

Private Sub UniGrid1_InsertRowError()
    MsgBox "You must input fill row before edit other row !", vbInformation, "DQHung"
End Sub

Private Sub UniGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
        PopupMenu mnuFile, , X * 15 + UniGrid1.Left, Y * 15 + UniGrid1.Top
    End If
End Sub
